import request from "@/utils/request";
import { AxiosPromise } from "axios";
import {BillPageVO, BillQuery, BillSummaryQuery} from "@/api/bill/types";

/**
 * 标准账单分页数据
 *
 * @param queryParams
 */
export function getBillPage(
	queryParams: BillQuery
): AxiosPromise<PageResult<BillPageVO[]>> {
	return request({
		url: '/api/v1/bill/page',
		method: 'get',
		params: queryParams
	});
}

/**
 * 导入标准账单
 *
 * @param file
 */
export function importBill(platformAndType: string, storeId: number, file: any) {
	const formData = new FormData();
	formData.append('file', file);
	return request({
		url: '/api/v1/sourceTable/sourceImport',
		method: 'post',
		params: { 'platformAndType': platformAndType, 'storeId': storeId},
		data: formData,
		headers: {
			'Content-Type': 'multipart/form-data'
		}
	});
}

/**
 * 标准账单单汇总分页数据
 *
 * @param queryParams
 */
export function getBillSummaryPage(
	queryParams: BillSummaryQuery
): AxiosPromise<[]> {
	return request({
		url: '/api/v1/bill/summaryPage',
		method: 'get',
		params: queryParams
	});
}

/**
 * 标准账单字段列表
 *
 * @param queryParams
 */
export function getBillColumnList(): AxiosPromise<[]> {
	return request({
		url: '/api/v1/bill/columnList',
		method: 'get'
	});
}

